/*
 * @Author: Stefan Liu
 * @Date: 2019-08-24 16:16:38
 * @LastEditTime: 2019-08-24 17:53:33
 */
/* eslint-disable import/no-mutable-exports */
import { getAuthority } from './authority'
let CURRENT = getAuthority() !== undefined ? getAuthority() : 'NULL'
/**
 * use  authority or getAuthority
 * @param {string|()=>String} currentAuthority
 */
const renderAuthorize = currentAuthority => {
  if (currentAuthority) {
    if (typeof currentAuthority === 'function') {
      CURRENT = currentAuthority()
    }
    if (
      Object.prototype.toString.call(currentAuthority) === '[object String]' ||
      Array.isArray(currentAuthority)
    ) {
      CURRENT = currentAuthority
    }
  } else {
    CURRENT = 'NULL'
  }
  console.log(CURRENT)
}

export { CURRENT }
export { renderAuthorize }
